package com.guet.mapper;

import com.github.pagehelper.Page;
import com.guet.DTO.CommentDTO;
import com.guet.Entity.Comment;
import com.guet.Entity.TemplateTopic;
import com.guet.Entity.Topic;
import com.guet.VO.CommentVO;
import com.guet.VO.TopicVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface TopicMapper {
    List<TopicVO> list(String type);

    TopicVO queryById(String id);

    Page<CommentVO> getCommentList(CommentDTO commentDTO);

    @Select("select count(id) from comment where topic_id = #{id}")
    Integer getReplyCount(Integer id);

    void add(Comment comment);

    @Select("select * from template_topic where user_id = #{userId}")
    TemplateTopic queryDraftByUserId(Long userId);

    @Delete("delete from template_topic where user_id = #{userId}")
    void deleteDraftByUserId(Long userId);

    void save(TemplateTopic newDraft);

    void insert(Topic topic);

    @Delete("delete from topic where id = #{id}")
    void deleteTopicById(String id);

    @Delete("delete from comment where topic_id = #{id}")
    void deleteCommentByTopicId(String id);

    @Delete("delete from comment where id = #{id}")
    void deleteCommentById(String id);

    @Select("select * from topic where id = #{id}")
    Topic selectTopic(Integer id);

    @Select("select * from comment where id = #{id}")
    Comment getCommentById(Integer id);
}
